package com.mcptt.config.ue.config.sub.sub;

import java.util.List;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.comm.CheckData;
import com.cloudptt.api.product.log.Log;
import com.mcptt.config.ue.config.sub.sub.sub.PrioritizedMcpttGroup;

public class McpttGroupCall {
	
	public static final String Name = "MCPTT-Group-Call";
	private static final String Name_MaxSimulCallN4 = "Max-Simul-Call-N4";
	private static final String Name_MaxSimulTransN5 = "Max-Simul-Trans-N5";
	
	private int maxSimulCallN4 = 0;
	private int maxSimulTransN5 = 0;
	private PrioritizedMcpttGroup prioritizedMcpttGroup = null;
	
	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			if(name.equals(Name_MaxSimulCallN4))
			{
				String value = subElem.getText();
				maxSimulCallN4 = CheckData.parseInt(value);
			}
			else if(name.equals(Name_MaxSimulTransN5))
			{
				String value = subElem.getText();
				maxSimulTransN5 = CheckData.parseInt(value);
			}
			else if(name.equals(PrioritizedMcpttGroup.Name))
			{
				prioritizedMcpttGroup = new PrioritizedMcpttGroup();
				prioritizedMcpttGroup.parse(subElem);
			}
		}  
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Name).append(">").append("\r\n");
		
		strBuf.append("    ").append("<").append(Name_MaxSimulCallN4).append(">");
		strBuf.append(maxSimulCallN4);
		strBuf.append("</").append(Name_MaxSimulCallN4).append(">").append("\r\n");
		
		strBuf.append("    ").append("<").append(Name_MaxSimulTransN5).append(">");
		strBuf.append(maxSimulTransN5);
		strBuf.append("</").append(Name_MaxSimulTransN5).append(">").append("\r\n");
		
		strBuf.append(prioritizedMcpttGroup);
		
		strBuf.append("</").append(Name).append(">").append("\r\n");

		return strBuf.toString();
	}
}
